Texttris
“An once of practice is better then a ton of knowledge.”
Proverb
Simple Complications
Everybody has played tetris at one time or another. A lot of people have started (and many never completed) their own take on it. I think if you complete this tutorial you will have something to be proud of. Accordingly this is much more demanding then the previous lessons. Try running texttris.gb with Basic4GL. Play a while. Try to imagine whats going on while the program is running. How does a piece fall, how does it rotate. Now take a look at texttrisnomove.gb. Everything is inplace except the input and movement code. Your job.
The specifics
Ok. What you have to program is the code that handles the user input and moves the piece around apropriatly. The first thing you need to know is what each key should do. Play texttris.gb for this purpouse. Secondly you need to know a few variables. X and Y are the current location of the (upperleft corner of the) piece, the arrays piecex and piecey are indexed 1 to 4 and are the positions relative to x,y where each square of the tetronimoe is (that is x+piecex(1),y+piecey(i) is the location of the first square). Movedown is a function that moves the piece down, and performs coresponding operations in case the piece is touching the ground. Startx, Starty is the starting position for a new piece.
Basically thats all you need to know to be able to do the job. Although some people might have some trouble with the rotation code, the basic linear algebra involved should be part of every programmers repertory so get your hand on a book or tutorial if you find you down have this stuff known cold.